package com.itzhoun.consumer;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author 周楠
 * @Date 2022/09/11/上午 12:43
 */
@Component
public class FanoutReceiver {

    @Order(0)
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value = "logs", type = "fanout") //绑定交换机
            )
    })
    public void receiver1(String message){
        System.out.println("广播中 receiver1获取的信息{}"+ message);

    }

    @Order(1)
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,
                    exchange = @Exchange(value = "logs", type = "fanout") //绑定交换机
            )
    })
    public void receiver2(String message){
        System.out.println("广播中 receiver2获取的信息{}"+ message);

    }
}
